/*
package com.young.shop.controller;

import com.young.shop.dao.UserDao;
import com.young.shop.pojo.entity.User;
import com.young.shop.service.UserService;
import com.young.shop.service.impl.UserServiceImple;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
@WebServlet("/checkEmail")
public class chexkEmailController extends BaseController {
    private UserService userService=new UserServiceImple();
    @Override
    protected void doPost(HttpServletRequest req , HttpServletResponse resp) throws ServletException, IOException {
        String emailParam = req.getParameter("email");
        User user = new User();
        user.setEmail(emailParam);

        //校验邮箱账号
        try{
            String message = validateParams(user);
            writerSucccessBaseRespVoToResponse(resp,message);
        }catch (RuntimeException e){
            writerFailedBaseRespVoToResponse(resp,e);
        }

//        String message = validateParams(user);
//        if (message!=null){
//
//        }
//
//        String aa = "aaaaaa";
//        writerSucccessBaseRespVoToResponse(resp,aa);
//        Exception exception = new Exception();
//        writerFailedBaseRespVoToResponse(resp,exception);
    }

    private String validateParams (User user) {
        //判断是否为空
        if (user.getEmail()==null||user.getEmail().trim().equals("")){
            throw new RuntimeException ("邮箱为空");
//            return "邮箱为空";
        }
        //判断是否存在
        boolean result = userService.existsByUserEmail(user);
        //true 代表已存在  false代表不存在
        if (result){
            throw new RuntimeException ("用户已存在");
//            return "用户已存在";
        }
        return null;
    }
}
*/
